home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Darth Fader 1.0 Source / Darth Fader / Gamma lib ƒ / gamma.h < prev   
Text File  |  1993-11-21  |  6KB  |  139 lines

  1. /**********************************************************************\
  2.  
  3. File:        gamma.h
  4.  
  5. Purpose:    This is the header file for gamma.c
  6.             
  7. Note:        This file was not written by the author of Darth Fader
  8.             and is not subject to the licensing terms of the GNU General
  9.             Public License.
  10.  
  11.  
  12. Darth Fader -=- fade in and out on system beep
  13. Copyright (C) 1993 Mark Pilgrim
  14.  
  15. This program is free software; you can redistribute it and/or modify
  16. it under the terms of the GNU General Public License as published by
  17. the Free Software Foundation; either version 2 of the License, or
  18. (at your option) any later version.
  19.  
  20. This program is distributed in the hope that it will be useful,
  21. but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23. GNU General Public License for more details.
  24.  
  25. You should have received a copy of the GNU General Public License
  26. along with this program in a file named "GNU General Public License".
  27. If not, write to the Free Software Foundation, 675 Mass Ave,
  28. Cambridge, MA 02139, USA.
  29.  
  30. \**********************************************************************/
  31.  
  32. // File "gamma.h" - Header for Altering the Gamma Tables of GDevices
  33.  
  34. // * ****************************************************************************** *
  35. //
  36. //    This library is intended as a general tool for manipulating the Gamma Tables
  37. //        of Graphics Devices, to ramp them up or down in order to achieve smooth
  38. //        screen fades. The source is included for programmers who want to convert
  39. //        the library to A4-based, but it is not commented for public consumption.
  40. //    The library defines 2 globals to save state data, but the entire Table 
  41. //        manipulation is performed with unlocked handles to be easy on your heap.
  42. //        The typical memory chunk is about 600 bytes for a 13" Monitor in 8-bit 
  43. //        depth, or about 1700 bytes for one in 24-bit color. Usage will vary.
  44. //    Of course, the Classic Mac cannot use Gamma Fades, only Mac II or later machines
  45. //        with attached monitors. (I don't know about the Color Classic tho’!). Also,
  46. //        GDevice manipulation needs to follow InitGraf() & InitWindows() calls.
  47. //    Please use the listed functions to see if you can use this code before you set
  48. //        it up. As usual, this stuff is not warranteed, guaranteed, or anything--
  49. //        use it at your own risk. It is not Apple-recommended for anything, but it
  50. //        worked for me, so there!
  51. //    
  52. //        Written:    12/17/92, Matt Slot, fprefect@engin.umich.edu                
  53. //        
  54. //        Updated:     3/13/93, MJS    (v1.1)                                            
  55. //                        •>    Updated the GammaAvail calls to be more honest.
  56. //                            Actually check to see if Grafix Devices are supported
  57. //                            on this machine w/o using Gestalt. Also, used the 
  58. //                            std. Toolbox calls to test the GDevice attributes.
  59. //                        •>    Removed extraneous calls to lock handles in several
  60. //                            locations.
  61. //                        •>    Fixed bug in DoOneGammaFade which failed if the device
  62. //                            could not be found in the list.
  63. //                        •>    Changed function prototypes to be more intuitive.
  64. //                        •>    Updated the descriptions in header file.
  65. //                        •>  Thanks to David Phillip Oster, oster@well.sf.ca.us,
  66. //                            for his numerous suggestions and criticisms. :)
  67. //        
  68. //        Updated:     11/9/93, MJS    (v1.1.1)                                    
  69. //                        •>    Fixed incompatibility with EvenBetterBusError...
  70. //                            OK, it was an obscure bug (dereferencing once too
  71. //                            often), but didnt seem to break except with EBBE.
  72. //        
  73. //        Updated:     11/9/93, MJS    (v1.1.2)                                    
  74. //                        •>    Left a Debugger() in the posted application.
  75. //    
  76. //        Oh yeah, this stuff is free to anyone interested in it.
  77. //
  78. // * ****************************************************************************** *
  79.  
  80. //    A quick signature
  81. #define kGammaUtilsSig    'GAMA'
  82.  
  83. //    To help check for compatibility
  84. #define kGetDeviceListTrapNum        0xAA29
  85.  
  86. // * ****************************************************************************** *
  87.  
  88. //    Internal data storage
  89. typedef struct globalGammas {
  90.     short size, dataOffset;
  91.     GammaTblHandle saved, hacked;
  92.     GDHandle theGDevice;
  93.     struct globalGammas **next;
  94.     } globalGammas, *globalGammasPtr, **globalGammasHdl;
  95.     
  96. // * ****************************************************************************** *
  97. // * ****************************************************************************** *
  98. // Function Prototypes
  99.  
  100. Boolean IsGammaAvailable(void);
  101. Boolean IsOneGammaAvailable(GDHandle theGDevice);
  102.  
  103. //    These routines help you determine whether you can use the Gamma Table Utils
  104. //        on the current machine. The first checks all attached monitors, and the 
  105. //        second just checks the indicated monitor. Each returns TRUE if you can 
  106. //        use the functions, or FALSE if you can't. • Note: Before calling any other
  107. //        Gamma Table function below, use this function to see if you are allowed.
  108.  
  109. // * ****************************************************************************** *
  110.  
  111. OSErr SetupGammaTools(void);
  112. OSErr DisposeGammaTools(void);
  113.  
  114. //    These routines must bracket any calls to the Gamma Table functions, perhaps
  115. //        at the head and tail of your main(). The first sets up the data structures
  116. //        necessary to save and restore the state of your monitors. The second
  117. //        disposes of all the internal data structures, but does not reset the
  118. //        monitors to their original states. Both return the error code if some
  119. //        part failed. 
  120.  
  121. // * ****************************************************************************** *
  122.  
  123. OSErr DoGammaFade(short percent);
  124. OSErr DoOneGammaFade(GDHandle theGDevice, short percent);
  125.  
  126. //    Use the first function to Fade each of your monitors to some percentage of their
  127. //        initial brightness (100 = bright, 0 = dim). Repeatedly call this to ramp your
  128. //        monitors up or down. The second function performs the same function, but only
  129. //        for the specified monitor. Both return any applicable error codes.
  130. //    Be sure to set up the necessary save-state data structures before you start by
  131. //        calling the compatibility and initialization functions. 
  132.  
  133. // * ****************************************************************************** *
  134.  
  135. OSErr GetDevGammaTable(GDHandle theGDevice, GammaTblPtr *theTable);
  136. OSErr SetDevGammaTable(GDHandle theGDevice, GammaTblPtr *theTable);
  137.  
  138. //    These routines are low-level interfaces to the device drivers for the monitors.
  139. //        Use them at your own risk.